/**
 * Copyright 2009 Adam Ruggles.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.google.code.sapien.service;

import java.io.Serializable;

import com.google.code.sapien.model.User;

/**
 * Interface for basic service operations on entity data models.
 * @author Adam
 * @version $Id: EntityService.java 25 2009-05-26 04:23:01Z a.ruggles $
 * 
 * Created on Feb 8, 2009 at 11:01:17 AM
 * @param <T> The entity data model class type.
 */
public interface EntityService<T> {
    /**
     * Adds an entity.
     * @param entity The entity data model to add.
     * @param creator The user creating the entity.
     */
    void add(T entity, User creator);
    /**
     * Returns an entity by the id.
     * @param id The id of the object.
     * @return The entity with the given id or <code>null</code> if not found. 
     */
    T get(Serializable id);
    /**
     * Updates an entity.
     * @param entity The entity data model to update.
     * @param remover The user updating the entity.
     */
    void remove(T entity, User remover);
    /**
     * Updates an entity.
     * @param entity The entity data model to update.
     * @param updator The user updating the entity.
     * @return The persisted instance of the entity.
     */
    T update(T entity, User updator);
}
